package com.lhkj.ct.meta.modules.warning.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lhkj.ct.base.model.dto.PageQuery;
import com.lhkj.ct.meta.modules.warning.model.entity.TblPsyConsRecord;
import com.lhkj.ct.meta.modules.warning.model.vo.PsyConsRecordVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;

/**
 * <p>
 * 心理咨询记录 Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2023-10-30
 */
public interface TblPsyConsRecordMapper extends BaseMapper<TblPsyConsRecord> {

    /**
     * 心理咨询 - 分页查询
     */
    IPage<TblPsyConsRecord> selectPages(Page<TblPsyConsRecord> page,
                                        @Param("record") TblPsyConsRecord consRecords,
                                        @Param("pageQuery") PageQuery pageQuery);

    @Select("select id, create_time, fun_sys_username(create_by) as create_by from tbl_psy_cons_record where pat_id = #{patId}")
    IPage<TblPsyConsRecord> selectHistoriesByUser(Page<TblPsyConsRecord> page,
                                                  @Param("patId") String patId);

    PsyConsRecordVo getReportInfo(@Param("id") String id);

    @Select("select id, pat_id, pat_name, fun_convert_dictionary(pat_sex, '${@com.lhkj.ct.base.constants.DictConstants@GENDER}') as pat_sex, pat_age, pat_birthday, pat_mobile, risk_level, evaluation_content, type, contacts, contact_phone, relationship, create_by, create_time, update_by, update_time from tbl_psy_cons_record where id = #{id}")
    TblPsyConsRecord getById(@Param("id") Serializable id);
}
